<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <!-- header -->
    <%@ include file="/WEB-INF/views/include/header.jsp" %>
</head>
<body class="no-skin">
<%--上传成功模态框--%>
<div class="shade" style="display: none;"></div>
<div class="warning" style="display: none;">
    <p class="title"><em></em><span class="close">X</span></p>
    <p class="cont"></p>
    <div class="la-square-jelly-box la-3x">
        <div></div>
        <div></div>
    </div>
</div>
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">
                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                       <%-- <div class="pull-left">
                            <button class="btn btn-sm btn-success" id="goodEval" onclick="goodEval()">好</button>
                            <button class="btn btn-sm btn-info"    id="normalEval" onclick="normalEval()">中</button>
                            <button class="btn btn-sm btn-danger"  id="badEval"    onclick="badEval()">差</button>
                            <button class="btn btn-sm btn-default"  id="edit-eval"    onclick="edit()">修改</button>
                        </div>--%>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <!-- jqGrid表格 -->
                        <table id="gridTable"></table>
                        <!-- jqGrid工具类 -->
                        <div id="gridPager"></div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>

    <%@ include file="/WEB-INF/views/include/dialog.jsp" %>
</div><!-- /.main-container -->
</div>

<!-- footer -->
<%@ include file="/WEB-INF/views/include/footer.jsp" %>

<script type="text/javascript">
    // 基本路径
    var baseUrl = "<s:url value="/insideDept/allinside"></s:url>"

    // jqgrid的表格高度
    var height = 320;
    // jqgrid表格行头的中文
    var colNames = ["", 'id','任务名称','任务内容 ','周期类型','时限',"任务状态","反馈类型","备注"];

    var colModel = [
        {name: 'sysId', width: 60, hidden: true, key: true},
        {name: 'sysId', width: 60, width:200,editable: false},
        {name: 'taskName', index: 'ruleName', width: 200, editable: true},
        {name: 'taskCont', index: 'ruleRatio', width: 200, editable: true},
        {name: 'timeType', index: 'timeType', width: 200, editable: true,formatter:timeTypeValue},
        {name: 'cycleValue', index: 'cycleValue', width: 200, editable: true},

        {name: 'taskState', index: 'taskState', width: 200, editable: true,formatter:taskStateValue},
        {name: 'backType', index: 'backType', width: 200, editable:   true,formatter:backTypeValue },
        {name: 'remarks', index: 'remarks', width: 200, editable: true},
        ];
   /* function typeFormatter(data){
        return  data == "1" ? "日常类型" : "其他类型"
    }*/


    // jqgrid的具体执行方法
    jqgrid({
        gridTableId: "#gridTable",
        gridPagerId: "#gridPager",
        autoScroll: false,
        shrinkToFit: false,
        onSelectRow: function (rowid, status) {
        },
        ondblClickRow:function (rowid) {
            /**
             * 打开二级页面
             */
            parent.openapp("/insideDept/itemTasks/"+rowid,rowid,"接收单位")
        }

    });

    function taskStateValue(data) {
        switch (data){
            case '0':
                return '未查看';
                break;

            case '3':
                return '逾期';
                break
            case '4':
                return '完成';
                break;

            default:
                return '办理中';
        }
    }
    function timeTypeValue(data) {
        switch (data){
            case 1:
                return '单时限';
                break;

            case 2:
                return '天';
                break
            case 3:
                return '周';
                break;
            case 4:
                return '月';
                break;
            case 5:
                return '季';
                break;
            case 6:
                return '多时限';
                break;

            default:
                return '无效设置';
        }
    }

    function backTypeValue(data) {
        switch (data){
            case '0':
                return '无新反馈';
                break;
            case '1':
                return '有新反馈';
                break;

            default:
                return '无新反馈';
        }
    }



    //清空选中行
    $("#cancelChecked").click(function () {
        $("#gridTable").jqGrid('resetSelection');
        rowids=[];
    });
    var rowids = [];//选中行id
    /**
     * 取消选中
     */
    function gridRemoveSelect(rowid) {
        rowids.remove(rowid);
    }

    /**
     * 添加选中
     */
    function gridAddSelect(rowid) {
        rowids.push(rowid);
    }

    /**
     * 重写Array
     */
    Array.prototype.remove = function (val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };

    /**
     * 重写Array
     */
    Array.prototype.indexOf = function (val) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == val) return i;
        }
        return -1;
    };
    // 显示创建对话框
    $("#create").click(function () {
        loadDialog({
            dialogTitle: '新增事项',
            dialogUrl: getUrl("create"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="create()">确认</button>' +
            '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>'
        });
    });

    /*编辑 detail*/
    $("#edit-eval").click(function () {
        showEditDialog({
            tableId: "#gridTable",
            dialogTitle: "事项编辑",
            dialogUrl: getUrl("edit"),
            dialogFoot: '<button type="button" class="btn btn-primary" onclick="detail()">确认</button>' +
            '<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>',
            errorTitle: "消息对话框",
            errorMutiSelectMessage: '您当前选中多行，请重新选择',
            errorUnSelectMessage: '您当前尚未选中一行，请选择后再试',
            errorOk: '确定'
        });
    });


    // 保存数据 新增
    function create() {
        // 先验证表单
        if(!$("#formDialog form").valid()) {
            return;
        }

        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("create"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }

    // 保存数据 编辑
    function detail() {
        executeSaveOrUpdate({
            formId: "#formDialog form",
            dialogId: "#formDialog",
            url: getUrl("edit"),
            tableId: "#gridTable",
            successMessage: "保存成功",
            successTitle: '保存对话框',
            failMessage: '保存失败',
            failTitle: '消息对话框'
        });
    }


    //删除
    $("#delete").click(function () {
        showDeleteDialog({
            url: getUrl("delete"),
            tableId: "#gridTable",
            confirmTitle: "确认对话框",
            confirmMessage: "是否确定删除?",
            confirmOk: "确定",
            confirmCancel: "取消",
            successMessage: "删除成功",
            successTitle: "消息对话框",
            failMessage: "删除失败",
            failTitle: "消息对话框",
            errorTitle: "警告提示框",
            errorMessage: "您当前尚未选中一行，请选择后再试",
            errorOk: "确定"
        });
    });

    /**
     * 弹出消息对话框
     * @param msg
     */
    function alertMessage(msg) {
        msg = msg == null ? '' : msg;
        bootbox.dialog({
            title: "消息对话框",
            message: msg,
            buttons: {
                "danger": {
                    "label": '确定',
                    "className": "btn-sm btn-danger"
                }
            }
        });
    }

    function badEval(){
        seachJqgirdData("#gridTable", {
            ruleId : "3"
        });
    }
    function goodEval(){
        seachJqgirdData("#gridTable", {
            ruleId : "1"
        });
    }
    function normalEval() {
        seachJqgirdData("#gridTable", {
            ruleId : "2",
        });
    }





</script>

</body>
</html>